package cz.possoft.base;

import cz.possoft.integration.ComponentManager;
import cz.possoft.integration.jbossmc.JBossMCComponentManager;

/**
 * Factory for base singleton components in PossoftGamesProject. Only initial singletons can be obtained here.
 * Other components should be obtained via microcontainer.
 * 
 * @author mposolda
 */
public class MainFactory {
	
	private static MainFactory mainFactorySingleton = null;
	
	/**
	 * ComponentManager should be only singleton in the whole PossoftNetGames project.
	 */
	private ComponentManager componentManagerSingleton;
	
	private static Object lock = new Object();
	
	/**
	 * Private constructor
	 */
	private MainFactory()
	{	
		componentManagerSingleton = JBossMCComponentManager.getInstance();
	}
	
	public static MainFactory getInstance()
	{
		if (mainFactorySingleton == null)
		{
			synchronized(lock)
			{
				if (mainFactorySingleton == null)
				{
					mainFactorySingleton = new MainFactory();
				}
			}
		}
		return mainFactorySingleton;
	}
	
	public ComponentManager getComponentManagerInstance()
	{
		return componentManagerSingleton;
	}

}
